//
//  GRXMineVC.m
//  1-MushroomStreet-自定义tabbar
//
//  Created by xmg on 15/12/8.
//  Copyright © 2015年 grx. All rights reserved.
//

#import "GRXMineVC.h"
#import "GRXHeaderCell.h"
#import "GRXMineFooterCell.h"

#import "GRXSettingController.h"
@interface GRXMineVC ()<UITableViewDataSource,UITableViewDelegate>

/**<#注释#>*/
@property (nonatomic, weak) UITableView *tableView;


/**<#name#>*/
@property (nonatomic,assign)CGFloat prefortY;



@end

@implementation GRXMineVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我我我";
    
    if (self.isLogin == NO) {
        return;
    }
    
    [self setSubViews];
    
    [self setUpNavigation];
}


- (void)setUpNavigation{
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"设置" style:0 target:self action:@selector(settingBtnClick)];

}


- (void)settingBtnClick{
    NSLog(@"点击了设置");
    GRXSettingController *settingVc = [[GRXSettingController alloc] initWithStyle:UITableViewStyleGrouped];
    
    // 隐藏底部条:条件:在跳转之前设置
    settingVc.hidesBottomBarWhenPushed = YES;
    
    [self.navigationController pushViewController:settingVc animated:YES];
    
}


- (void)setSubViews{
    
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    tableView.backgroundColor = [UIColor clearColor];
    tableView.delegate = self;
    tableView.dataSource = self;

    
    self.tableView = tableView;
    [self.view addSubview:tableView];
    

    
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    
    //不分组的时候,设置这个footView,当cell有值的时候才会显示分隔线
    tableView.tableFooterView = [[UIView alloc] init];
    
    if (indexPath.row == 0) {
        static NSString *ID = @"cell0";
        GRXHeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
        
        if (!cell) {
            cell = [[GRXHeaderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.contentView.backgroundColor = [UIColor redColor];
        return cell;
    }else if(indexPath.row == 1){
        static NSString *ID = @"cell2";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        }
        cell.contentView.backgroundColor = [UIColor lightGrayColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else {

        
        static NSString *ID = @"cell1";
        GRXMineFooterCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
        
        if (!cell) {
            cell = [[GRXMineFooterCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        return cell;
        
    }
   return nil;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return 246;
    }else if (indexPath.row == 1){
        return 15;
    }
    return 400;
}


@end
